//
// C++ Header: Product
//
// Description: this class stores details on a product by being fed from a file
//
//
// Author:  <>, (C) 2007
//
//
//

#ifndef PRODUCTH
#define PRODUCTH

#include <fstream> //for ifstream
#include <iostream> // for cout
#include <sstream> //for strinsgream conversions string => float ...
#include <iomanip> //for setw
using namespace std;

class Product
{
	public:
		//fills the product with the given info
		//if the name is not provided or "", isUndefined is set to true
		Product ( string name="", float BuyingPrice=0, float SellingPrice=0 ,int quantity=0 );
		
		//loads product info from a filestream using the latter's position in file to eat the first product
		//note that the filestream's pointer is moved when a product is "eaten"
		//if nothing is eaten, isUndefined is set to true
		Product ( istream& filestream );
		
		//is this object undefined or missing at least a name ?
		operator bool() const;
		
		//returns the profit gained if stocks are sold out
		float getPredictedProfit();

		//lets us do cout << someProductInstance, which prints the latter's details nicely
		friend ostream& operator<< ( ostream& out, Product& prod );
		
		//the product details
		string name; //ex: Merit Spaghetti 50mL
		float BuyingPrice; //in dollars
		float SellingPrice; //in dollars
		int quantity; //number of items in stock
		
	
	protected:
		//this is set to true by default or if not even a name has been found/provided
		bool isUndefined; 
};

ostream& operator<< ( ostream& out, Product& prod );
#endif
